package com.bitbakery.plugin.lisp.lang;

import com.bitbakery.plugin.lisp.lang.formatting.LispFormattingModelBuilder;
import com.bitbakery.plugin.lisp.lang.lexer.LispSyntaxHighlighter;
import com.bitbakery.plugin.lisp.lang.psi.CLElement;
import com.intellij.formatting.FormattingModelBuilder;
import com.intellij.ide.structureView.StructureViewBuilder;
import com.intellij.ide.structureView.StructureViewModel;
import com.intellij.ide.structureView.TreeBasedStructureViewBuilder;
import com.intellij.lang.Commenter;
import com.intellij.lang.Language;
import com.intellij.lang.PairedBraceMatcher;
import com.intellij.lang.ParserDefinition;
import com.intellij.lang.annotation.Annotator;
import com.intellij.lang.findUsages.FindUsagesProvider;
import com.intellij.lang.folding.FoldingBuilder;
import com.intellij.openapi.fileTypes.SyntaxHighlighter;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public class LispLanguage extends Language {
    private static final Annotator COMMON_LISP_ANNOTATOR = new LispAnnotator();

    public LispLanguage() {
        super("Common Lisp");
    }

    @NotNull
    public ParserDefinition getParserDefinition() {
        return new LispParserDefinition();
    }

    @NotNull
    public PairedBraceMatcher getPairedBraceMatcher() {
        return new LispPairedBraceMatcher();
    }

    @NotNull
    public SyntaxHighlighter getSyntaxHighlighter(Project project, final VirtualFile virtualFile) {
        return new LispSyntaxHighlighter();
    }

    @NotNull
    public Commenter getCommenter() {
        return new LispCommenter();
    }

    public FoldingBuilder getFoldingBuilder() {
        return new LispFoldingBuilder();
    }


    @NotNull
    public StructureViewBuilder getStructureViewBuilder(@NotNull final CLElement root) {
        return new TreeBasedStructureViewBuilder() {
            public StructureViewModel createStructureViewModel() {
                return new LispStructureViewModel(root);
            }
        };
    }

    @Nullable
    public FormattingModelBuilder getFormattingModelBuilder() {
        return new LispFormattingModelBuilder();
    }

    public Annotator getAnnotator() {
        return COMMON_LISP_ANNOTATOR;
    }

    @NotNull
    public FindUsagesProvider getFindUsagesProvider() {
        return new LispFindUsagesProvider();
    }
}
